<?php

	echo <<<TEXT
{
	show: function() {
	var tree_loader = new Ext.tree.TreeLoader({
	dataUrl: '../php/tree_loader.php'
});

var root_node = new Ext.tree.AsyncTreeNode({
	text: 'Home',
	draggable: false,
	id: '0'
});

var tree_panel = new Ext.tree.TreePanel({
	root: root_node,
	region: 'west',
	title: 'Folders',
	width: 100,
	loader: tree_loader,
	containerScroll: true,
	split: true
});

var grid_store = new Ext.data.SimpleStore({
	fields: [
		{ name: 'filename' },
		{ name: 'date_mod' },
		{ name: 'type' },
		{ name: 'path' }
	]
});

var data = [
	['File 1', '10/10/2009', 'jpg'],
	['File 2', '12/10/2009', 'gif']
];

grid_store.loadData(data);

var grid_panel = new Ext.grid.GridPanel({
	store: grid_store,
	columns: [
		{ header: 'Name', width: 80 },
		{ header: 'Date Modified', width: 100 },
		{ header: 'Type', width: 80 },
		{ header: 'Path', width: 80 }
	],
	region: 'center'
});

grid_panel.addListener('rowclick', function(grid, rowIndex, e) {
	var record = grid.getStore().getAt(rowIndex);
	var data = record.get('path');
	var filefield = new Ext.form.TextField(Ext.get('filename'));
	filefield.setValue(data);
});

tree_panel.addListener('click', function(node, e) {
	Ext.Ajax.request({
		url: '../php/grid_loader.php?folder=' + node.text,
		success: function(response) {
			grid_store.loadData(eval(response.responseText));
		}
	});
});

var panel = new Ext.Panel({
	layout: 'border',
	baseCls: 'x-plain',
	region: 'center',
	items: [ grid_panel, tree_panel	]
});

var panel2 = new Ext.form.FormPanel({
	region: 'south',
	baseCls: 'x-plain',
	height: 60,
	labelWidth: 50,
	bodyStyle: 'padding:5px 5px 0',
	defaultType: 'textfield',
	items: [
		{
			fieldLabel: 'Filename',
			name: 'filename',
			id: 'filename',
			anchor: '100%'
		},
		{
			fieldLabel: 'Filetype',
			name: 'filetype',
			anchor: '100%'
		}
	]
});

var win = new Ext.Window({
	title: 'Open Dialog',
	width: 400,
	height: 300,
	layout: 'border',
	items: [ panel, panel2 ],
	buttons: [
		{ text: 'Open', handler: function() { alert(Notepad.openDialog());} },
		{ text: 'Cancel' }
	]
});

win.show();
	}
}
TEXT

?>